<%@ Page Language="VB" MasterPageFile="~/Default.master" AutoEventWireup="false" CodeFile="Team.aspx.vb" 
    Inherits="Statistics_Team" title="Bridgwater Sports | Team Stats" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    
    <div id="body">
    
        <div class="fullwidth">
            <table cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td>
                        <asp:HyperLink ID="AllStats" runat="server" Text="All Statistics" NavigateUrl="~/CricketStats/Default.aspx" />&raquo;
                        <asp:Label ID="TeamStats" runat="server" />
                    </td>
                    <td align="right">
                        <asp:DropDownList ID="ddlTeams" runat="server" AutoPostBack="True" DataSourceID=""
                            DataTextField="TeamName" DataValueField="TeamID">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlTeams" />
            </Triggers>
            <ContentTemplate>

                <div id="columnleft">
                    <div class="leftblock" style="padding-bottom: 30px;">
                    <h2><asp:Label ID="TeamNamelbl" runat="server" /></h2>
                    <%  If IsGameRecorderOrAdmin() = True Then %>
                    
                        <div style="float: right; margin-top: -15px;">
                            <asp:LinkButton ID="lBtnCaptains" runat="server" Text="Change" OnClientClick="document.getElementById('divChangeCapts').style.display=''; return false;" />
                        </div>
                        <div id="divChangeCapts" style="display: none; margin-bottom: 15px;">
                            <ul style="list-style: none; margin: 0px;">
                                <li style="padding-bottom: 4px;">
                                    Captain:
                                    <asp:DropDownList ID="ddlCaptain" runat="server"
                                     DataValueField="PlayerId" DataTextField="PlayerName" CssClass="captainchangedropdowns">
                                    </asp:DropDownList>
                                </li>
                                <li style="padding-bottom: 4px;">
                                    Vice Captain:
                                    <asp:DropDownList ID="ddlViceCaptain" runat="server"
                                     DataValueField="PlayerId" DataTextField="PlayerName" CssClass="captainchangedropdowns">
                                    </asp:DropDownList> 
                                </li>
                                <li style="width: 100%; text-align: right;">
                                    <asp:LinkButton ID="lBtnUpdateCaptains" runat="server">Done!</asp:LinkButton>
                                </li>
                            </ul>
                        </div>
                    
                    <%  End If%>
                    
                    <asp:ListView ID="lvCaptains" runat="server">
                        <LayoutTemplate>
                            <ul style="list-style: none; float: left; width: 100%; margin: 0px;">
                                <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                            </ul>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <li style="float: left; width: 40%; margin-bottom: 4px;">Captain</li>
                            <li style="float: left; width: 59%;font-weight: bold; margin-bottom: 4px;"><%#Eval("Captain")%></li>
                            <li style="float: left; width: 40%;">Vice Captain</li>
                            <li style="float: left; width: 59%;font-weight: bold;"><%#Eval("ViceCaptain")%></li>
                        </ItemTemplate>
                    </asp:ListView>
                    
                    </div>
                    
                    <% If IsGameRecorderOrAdmin() = True Then%>
                        <div class="leftblock" style="display: none;">
                            <h2>Add Player</h2><br />
                            <asp:DropDownList ID="MembersDropDown" Width="100px" runat="server" DataSourceID="" DataTextField="PlayerName" DataValueField="PlayerId">
                            </asp:DropDownList><br />
                            <asp:ObjectDataSource ID="MembersDataSource" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="FetchAll" TypeName="ClubStarterKit.Data.MemberInfoController"></asp:ObjectDataSource>
                            <asp:LinkButton ID="AddPlayer" runat="server" Text="Add Player To Team" />
                        </div>
                    <% End If %>
                </div>
                
                <div id="columnright">
                    <div class="rightblock">
                    <h2>Team Statistics</h2>
                    <br />
                        <asp:GridView runat="server" Width="100%" ID="gvTeamStats" GridLines="None" 
                            AutoGenerateColumns="False">
                            <HeaderStyle HorizontalAlign="Left" />
                            <RowStyle Font-Size="12" />
                            <Columns>
                                <asp:BoundField DataField="Played" HeaderText="Played" />
                                <asp:BoundField DataField="Won" HeaderText="Won" />
                                <asp:BoundField DataField="Lost" HeaderText="Lost" />
                                <asp:BoundField DataField="Drawn" HeaderText="Drawn" />
                                <asp:BoundField DataField="Points" HeaderText="Total Points" />
                            </Columns>
                        </asp:GridView>
                    </div>
                </div>
                
                <div class="fullwidth">            
                    <h2>Player Statistics</h2><br />
                    <h3>Batting</h3><br />

                    <asp:GridView ID="gvBatting" AllowSorting="false" runat="server" DataSourceID=""
                        GridLines="None" CellPadding="2" AutoGenerateColumns="False" Width="701px">
                     <AlternatingRowStyle BackColor="#FFF3A5" />
                     <RowStyle Font-Size="11" />
                        <Columns>
                            <asp:TemplateField HeaderText="Player" ItemStyle-Width="40%" ItemStyle-Font-Size="10" SortExpression="Player">
                                <ItemTemplate>
                                    <asp:HyperLink ID="PlayerHyperLink" runat="server" Text='<%# Eval("Player.PlayerName") %>' NavigateUrl='<%# "~/CricketStats/player.aspx?playerid=" & Eval("Player.PlayerId").ToString() %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField SortExpression="Mins" DataField="Mins" HeaderText="Mins" />
                            <asp:BoundField SortExpression="NOs" DataField="NOs" HeaderText="N.O's" />
                            <asp:BoundField SortExpression="DNBs" DataField="DNBs" HeaderText="D.N.B's" />
                            <asp:BoundField SortExpression="Fours" DataField="Fours" HeaderText="Total Fours" />
                            <asp:BoundField SortExpression="Sixes" DataField="Sixes" HeaderText="Total Sixes" />
                            <asp:BoundField SortExpression="TotalRuns" DataField="TotalRuns" HeaderText="Total Runs" />
                        </Columns>
                    </asp:GridView>
                    
                    <br />
                    
                    <h3>Bowling</h3><br />
                    
                    <asp:GridView ID="gvBowling" runat="server" DataSourceID="" GridLines="None" 
                        AutoGenerateColumns="False" Width="701px" CellPadding="2">
                    <AlternatingRowStyle BackColor="#FFF3A5" />
                    <RowStyle Font-Size="11" />
                        <Columns>
                            <asp:TemplateField HeaderText="Player" ItemStyle-Font-Size="10" ItemStyle-Width="40%">
                                <ItemTemplate>
                                    <asp:HyperLink ID="PlayerHyperLink" runat="server" Text='<%# Eval("Player.PlayerName") %>' NavigateUrl='<%# "~/CricketStats/player.aspx?playerid=" & EVal("Player.PlayerId").ToString() %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField SortExpression="Overs" DataField="Overs" HeaderText="Overs" />
                            <asp:BoundField SortExpression="Fours" DataField="Maidens" HeaderText="Maidens" />
                            <asp:BoundField SortExpression="Sixes" DataField="Wickets" HeaderText="Wickets" />
                            <asp:BoundField SortExpression="Runs" DataField="Runs" HeaderText="Runs" />
                            <asp:BoundField SortExpression="Catches" DataField="Catches" HeaderText="Catches" />
                        </Columns>
                    </asp:GridView>
                    
                </div>
                <% If IsGameRecorderOrAdmin() = True Then%>
                    <div class="">
                        <asp:Label ID="lblDebug" runat="server" Text=""></asp:Label>
                    </div>
                <% End If %>
                
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>